Skip to content

fix(clickhouse): a schema read rejected by the server memory limit is not a finding - #35

Merged
fm4v merged 1 commit into
ClickHouse:mainfrom
groeneai:fix-clickhouse-schema-read-memory-limit
Nov 25, 2026
Merged

fm4v merged 1 commit into
ClickHouse:mainfrom
groeneai:fix-clickhouse-schema-read-memory-limit

Conversation

@groeneai

@groeneai groeneai commented Nov 25, 2026 •

Copy link
Copy Markdown

The 2026-11-25 master nightly (SQLancer (arm_release), reproducer) reported this, and worker database9 was gone for the remaining 3h51m of the run (Threads shut down: 1):

java.sql.SQLException: Code: 241. DB::Exception: (total) memory limit exceeded: would use 55.38 GiB (attempt to allocate chunk of 0.00 B), current RSS: 55.56 GiB, maximum: 53.49 GiB. ... [client-v2, query: SHOW TABLES FORMAT RowBinaryWithNamesAndTypes]
	at sqlancer.clickhouse.ClickHouseSchema.getTableNames(ClickHouseSchema.java:564)
	at sqlancer.clickhouse.ClickHouseSchema.fromConnection(ClickHouseSchema.java:499)
	at sqlancer.clickhouse.ClickHouseProvider$ClickHouseGlobalState.readSchema(ClickHouseProvider.java:111)
	at sqlancer.GlobalState.updateSchema(GlobalState.java:145)
	at sqlancer.SQLGlobalState.executeEpilogue(SQLGlobalState.java:19)
	at sqlancer.GlobalState.executeStatement(GlobalState.java:109)
	at sqlancer.clickhouse.ClickHouseProvider.generateDatabase(ClickHouseProvider.java:122)

While its total memory is above the limit, the server rejects every new HTTP request at authentication (ClickHouse/ClickHouse#95003), hence chunk of 0.00 B and the empty query id: the other workers' queries had pushed the server over, SHOW TABLES used nothing. The fuzzer already expects this error for generated statements (memory limit exceeded in ClickHouseErrors) and for its setup commands (runSetupCommandsWithTolerance), but not for the schema read after each DDL statement, so the raw SQLException became a finding and ended the worker.

Now readSchema() throws IgnoreMeException for an error that ClickHouseErrors.isToleratedException accepts, as the oracles' own bookkeeping reads already do, and rethrows anything else. The worker moves on to a fresh database.

Checked: mvn verify -DskipTests=true -Djacoco.skip=true passes. Against master 1c87825f446d (debug build, .claude/clickhouse-config/ overrides), 10 threads, 10 min per run, before and after on one server:

run before with this PR
server put over its limit for 10 s every 60 s (config reload of max_server_memory_usage_to_ram_ratio), --num-queries 50, TLPWhere,NoREC 7 findings with this signature (SHOW TABLES, DESCRIBE), 9 of 10 workers dead none with this signature, 1 worker dead (an unrelated CANNOT_CONVERT_TYPE mutation finding, also seen before)
unbiased, the job's oracle list no finding with this signature in 2 runs, 211,028 and 129,554 queries none, 177,764 queries; no schema read failed, so the new branch never ran

Related: ClickHouse/ClickHouse#128538

🤖 Generated with Claude Code


Note

Low Risk
Single try/catch around schema introspection; only redirects already-whitelisted ClickHouse errors to the existing ignore path.

Overview
Schema reads after DDL now treat server-side errors that are already on ClickHouse’s tolerated list (e.g. memory limit exceeded when the server is over RAM and rejects SHOW TABLES) as IgnoreMeException, so the worker skips the database instead of reporting a finding and shutting down.

Anything not accepted by ClickHouseErrors.isToleratedException is still rethrown unchanged. This matches how generated statements, setup commands, and oracle bookkeeping already handle the same failures.

Reviewed by Cursor Bugbot for commit 3233257. Bugbot is set up for automated code reviews on this repo. Configure here.

… not a finding

When the server is above its total memory limit, it rejects every new
request before authentication with `(total) memory limit exceeded`
(Code 241, `attempt to allocate chunk of 0.00 B`, empty query id), even a
trivial `SHOW TABLES`. The fuzzer already treats this error as expected for
generated statements and for its setup commands, but not for the schema
read that runs after every DDL statement. The raw SQLException from
`ClickHouseSchema.fromConnection` became a finding and ended the worker
thread for the rest of the run.

Skip the iteration with IgnoreMeException when the schema read fails with
an error from `ClickHouseErrors.isToleratedException`, like the other
harness reads do, and rethrow anything else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fm4v
fm4v merged commit 2d1280e into ClickHouse:main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants